<template>
  <div id="app">
    <router-view />
    <loading v-if="$store.state.loading" />
  </div>
</template>

<script>
import loading from "./components/loading";
export default {
  computed: {
    loading() {
      return this.$store.state.loading;
    }
  },
  mounted() {
    sessionStorage.setItem("isOpnePage", "true"); //表示十分进页面
  },
  watch: {
    // 监听,当路由发生变化的时候执行
    $route: {
      handler(val, oldVal) {},
      // 深度观察监听
      deep: true
    },
    //监听loading,如果关闭，文案清空，防止下次文案错误
    loading(val) {
      if (!val) {
        this.$store.state.loadingText = "";
      }
    }
  },
  components: { loading },
  name: "App"
};
</script>

